template <class T> void SafeRelease(T **ppT)
{
	if (*ppT)
	{
		(*ppT)->Release();
		*ppT = NULL;
	}
}

#define ERROR_RETURN(hr, msg) {HRESULT _hr = hr; if(FAILED(_hr)){ Release(); return _hr; }}